<template>
    <view class="wrap">
        <Template0 :emptyList="emptyList" templateStatus="templete" v-if="vuex_templateData.code === 'template0'"></Template0>
        <Template1 :emptyList="emptyList" templateStatus="templete" v-if="vuex_templateData.code === 'template1'"></Template1>
        <view class="bottom-wrap" @click="useTemplate"><view class="btn">就用它</view></view>
    </view>
</template>
<script>
import Template0 from '../components/template/Template0.vue';
import Template1 from '../components/template/Template1.vue';
export default {
    name: '',
    data() {
        return {
            emptyList: [],
            randomUrl: [
                require('../static/posterPage/random/0.jpg'),
                require('../static/posterPage/random/1.jpg'),
                require('../static/posterPage/random/2.jpg'),
                require('../static/posterPage/random/3.jpg'),
                require('../static/posterPage/random/4.jpg'),
                require('../static/posterPage/random/5.jpg'),
                require('../static/posterPage/random/6.jpg'),
                require('../static/posterPage/random/7.jpg'),
                require('../static/posterPage/random/8.jpg'),
                require('../static/posterPage/random/9.jpg')
            ]
        };
    },
    props: {},
    computed: {},
    onLoad() {
        this.$uniPromise.setTitle(this.vuex_templateData.name);
        this.emptyList = this.creatEnptyObj(this.vuex_templateData.modeArr.length);
    },
    onShow() {},
    methods: {
        creatEnptyObj(len) {
            let list = [];
            for (let i = 0; i < len; i++) {
                list.push({
                    image_url_c: this.getRandomPath()
                });
            }
            return list;
        },
        getRandomPath() {
            let randomNum = parseInt(this.randomUrl.length * Math.random());
            let url = this.randomUrl[randomNum];
            this.randomUrl.splice(randomNum, 1);
            return url;
        },
        // 获取模板数据
        useTemplate() {
            uni.redirectTo({
                url: '/pages/compoundPages/selectPhotos/selectPhotos'
            });
        }
    },
    watch: {},
    components: { Template0,Template1 }
};
</script>
<style lang="scss" scoped>
.bottom-wrap {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 750rpx;
    height: 220rpx;
    z-index: 111;
    background-image: linear-gradient(rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.6) 100%);
    display: flex;
    justify-content: center;
    .btn {
        margin-top: 74rpx;
        width: 600rpx;
        height: 86rpx;
        background-image: linear-gradient(45deg, #47c649 0%, #5ad25c 100%), linear-gradient(#0ac26b, #0ac26b);
        border-radius: 10rpx;
        font-size: 30rpx;
        color: #ffffff;
        line-height: 30rpx;
        display: flex;
        justify-content: center;
        align-items: center;
    }
}
</style>
